<template>
	<view>
		<view >
			<uni-segmented-control :values="items" styleType="text">
				
			</uni-segmented-control>
			
			
		</view>
		<uni-list>
			<uni-list-item 
				v-for="(item,index) in books"
				:key = index
				:title="item.title"
				:note="item.author"
				:to="`../bookinfo/bookinfo?id=${item.id}`"
			></uni-list-item>

		</uni-list>
	</view>
</template>

<script>
	import {fetchList} from '../../api/api.js'
	export default {
		data() {
			return {
				items: ['最新', '最热', '评分', '完结', '连载'],
				books: []
			};
		},
		onLoad(option) {
			console.log(option)
			const { title, category } = { ...option }
			uni.setNavigationBarTitle({
				title: title
			});
			
			this.init("latest",category)
		},
		methods: {
			init(type, category) {
				fetchList(type, category, 1).then(res => {
					console.log(res)
					this.books = res.data.data.data;
				})
			}
		}
		
	}
</script>

<style lang="scss">
.button-group {
	display: flex;
	flex-direction: row;
	
	uni-navigator {
		display: flex;
		
		
	}
}
</style>
